class CreateTours < ActiveRecord::Migration
  def self.up
    create_table :tours, :force => true do |t|
      t.references :tour_category, :null => false
      t.string :name, :null => false
      t.text :description
      t.text :summary
      # 使用更有意义的字段名，因此不用t.references :attachment
#      t.column "picture_id", :integer
      
      t.timestamps
    end
    
    execute "alter table tours 
             add constraint fk_tour_tour_category 
             foreign key (tour_category_id) references tour_categories(id)"
#    execute "alter table tours 
#             add constraint fk_tour_attachment 
#             foreign key (picture_id) references attachments(id)"
  end
  
  def self.down
    drop_table :tours
  end
end
